package com.jiyinit.web.core.business.dao;

import com.jiyinit.core.framework.base.paging.PagingResult;
import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.core.framework.dao.mybatis.paginator.domain.PageBounds;
import com.jiyinit.web.core.business.dto.UserAttendanceRequest;
import com.jiyinit.web.core.business.entity.TabUserAttendanceEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

 /**
  * 考勤dao
  * @author liuzongguang
  * @create 2018/8/29 16:37
  */
@Repository("core.tabUserAttendanceDao")
public class TabUserAttendanceDao {
    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(TabUserAttendanceDao.class);

    private String SQLID = "core.attendance.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;

     /**
      * 保存考勤
      * @author liuzongguang
      * @create 2018/8/29 16:49
      */
    public int insert(UserAttendanceRequest request) {
        return mybatisDaoContext.save(SQLID + "insert", request);
    }

     /**
      * 查询考勤
      * @author liuzongguang
      * @create 2018/8/29 16:50
      */
    public PagingResult<TabUserAttendanceEntity> getAttendanceList(UserAttendanceRequest request){
        PageBounds pageBounds = new PageBounds();
        pageBounds.setLimit(request.getLimit());
        pageBounds.setPage(request.getPage());
        return mybatisDaoContext.findForPage(SQLID + "getAttendanceList", TabUserAttendanceEntity.class, request, pageBounds);
    }
}
